<template>
  <el-form ref="form" :model="form" :rules="rules" label-width="80px" style="width:50%">
    <el-form-item label="企业编号">
      <el-input v-model="form.id" :disabled="true"></el-input>
    </el-form-item>
    <el-form-item label="企业名称" prop="name">
      <el-input v-model="form.name"></el-input>
    </el-form-item>
    <el-form-item label="证件类型" prop="type">
      <el-select v-model="form.type" placeholder="请选择证件类型">
        <el-option label="统一社会信用代码" value="统一社会信用代码"></el-option>
        <el-option label="组织机构代码" value="组织机构代码"></el-option>
        <el-option label="其他证件类型" value="其他证件类型"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="成立日期" prop="date">
      <el-date-picker type="date" placeholder="选择日期" v-model="form.date" style="width: 100%;"></el-date-picker>
    </el-form-item>
    <el-form-item label="证件号码" prop="num">
      <el-input v-model="form.num"></el-input>
    </el-form-item>
    <el-form-item label="注册资本" prop="capital">
      <el-input v-model="form.capital"></el-input>
    </el-form-item>
    <el-form-item label="详细地址" prop="address">
      <el-input v-model="form.address"></el-input>
    </el-form-item>
    <el-form-item label="职工人数" prop="peonum">
      <el-input v-model="form.peonum"></el-input>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">立即修改</el-button>
      <el-button>取消</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
  export default {
    data() {
      return {
        form: {
          id: 'c1234567890',
          name: '小度同学',
          type: '组织机构代码',
          date: '1998-11-23',
          num: '933566666525',
          capital: '2000000',
          address: '中国-深圳',
          peonum: '1200'
        },
        rules: {
          name: [
            { required: true, message: '请输入企业名称', trigger: 'blur' },
          ],
          type: [
            { required: true, message: '请选择证件类型', trigger: 'blur' },
          ],
          date: [
            { required: true, message: '请选择成立日期', trigger: 'blur' },
          ],
          num: [
            { required: true, message: '请输入证件号码', trigger: 'blur' },
          ],
          capital: [
            { required: true, message: '请输入注册资本', trigger: 'blur' },

          ],
          address: [
            { required: true, message: '请输入详细地址', trigger: 'blur' },
          ],
          peonum: [
            { required: true, message: '请输入职工人数', trigger: 'blur' },

          ],
        }
      }
    },
    created() {
      this.form.id = this.$route.query.id
      this.form.name = this.$route.query.name
      this.form.type = this.$route.query.type
      this.form.date = this.$route.query.date
      this.form.num = this.$route.query.num
      this.form.capital = this.$route.query.capital
      this.form.address = this.$route.query.address
      this.form.peonum = this.$route.query.peonum
    },
    methods: {
      onSubmit() {
        this.$axios.post(`/api/EnterpriseReviseController/reviseEnterprise`, this.$qs.stringify({
          enterpriseId: this.form.id,
          enterpriseName: this.form.name,
          cardType: this.form.type,
          enterpriseDate: this.form.date,
          cardId: this.form.num,
          capital: this.form.capital,
          address: this.form.address,
          workes: this.form.peonum

        }))
        console.log('submit!');
        this.form.date = this.form.date.toLocaleString('chinese', { hour12: false }).split('/').join('-')
        let obj2 = this.form
        if (obj2.name === '' || obj2.type === '' || obj2.date === '' || obj2.num === '' || obj2.capital === '' || obj2.address === '' || obj2.peonum === '') {
          this.$message({
            message: '您输入的信息不全，请输入所有信息！',
            type: 'warning'
          });
        } else {

        }
      }
    }
  }
</script>